const express = require('express');
const router = express.Router();
const User = require('../database/redis/userDao');
const interest = require('../database/mysql/interestsDao');

router.get('/', async function (req, res, next) {

    if (req.session.userId != null) {
        let userData = await User.asyncGetDataById(req.session.userId);
        //如果找不到会返回null
        if (userData != null) {
            //用户信息写入模板引擎
            res.locals.interest = await interest.getAllInterests();
            res.locals.userData = userData;
            res.render('user_content.ejs');
            return
        }
    }
    res.redirect('/login');
})

module.exports = router;